package com.shujia

import scala.io.{BufferedSource, Source}

object Demo18Implicit03 {
  implicit class ImplicitClass(path:String){

    def loadData():List[String] ={
      val bs: BufferedSource = Source.fromFile(path)
      val lineList:List[String]  = bs.getLines().toList
      bs.close()
      lineList
    }

  }

  def main(args: Array[String]): Unit = {
    // 3、隐式转换类
    val words = new ImplicitClass("scala/data/words.txt")
    words.loadData().foreach(println)

    val subject = new ImplicitClass("scala/data/subject.txt")
    subject.loadData().foreach(println)

    "scala/data/students.txt".loadData().foreach(println)
    "scala/data/score.txt".loadData().foreach(println)


  }

}

